﻿using System;
using System.Collections.Generic;

using E.BLL;
using E.Model;
using E.Enum;
using E.Web.UI.Page;

using X.Common;
using X.Pager;
using X.Pager.List;

namespace E.Web.Teacher.internals.publics.exam
{
    public partial class List : TeacherBasePage
    {
        public IDictionary<int, string> categoryList = EnumClass.GetExamCategoryList();
        public IList<DictAreaModel> areaList = new List<DictAreaModel>();
        public IList<ShortExamInfoModel> examList = new List<ShortExamInfoModel>();
        public Dictionary<int, string> certificateList;
        public int categoryid;
        //public int relationid;
        public int certificateid;
        public int courseid;
        public string act;

        protected override void ShowPage()
        {
            ExamBLL bll = new ExamBLL();
            areaList = GetTeacherAreaList(teacherid);
            act = XRequest.GetString("act");

            certificateList = (new CourseBLL()).GetAllInternalPublicProjectList();

            categoryid = XRequest.GetInt("ExamCategorySlt", -1);
            //relationid = XRequest.GetInt("RelationSlt", -1);

            courseid = XRequest.GetInt("CourseSlt", -1);
            certificateid = XRequest.GetInt("CertificateSlt", -1);

            if (ispost || act == "s")
            {
                SearchExamModel searchModel = new SearchExamModel();
                searchModel.Title = "";
                searchModel.CategoryID = EnumExamCategory.CourseExam;
                searchModel.CourseCertificateID = courseid;
                searchModel.CertificateID = certificateid;

                searchModel.AreaID = -1;
                searchModel.StartFromTime = "";
                searchModel.StartToTime = "";

                ExamListModel listModel = new ExamListModel();

                CheckPageIndexValue(XRequest.GetInt("s", 1) - 1, XRequest.GetInt("g", 0), XRequest.GetInt("z", customerPageSize));

                listModel = bll.GetInternalPublicExamListByCondition(searchModel, customerPageSize, pageIndex);
                if (listModel.TotalCount > 0)
                {
                    count = listModel.TotalCount;
                    examList = listModel.List;
                    PagerBase pager = new ListPager(count, pageIndex, currentPgGroup, customerPageSize, defaultPagesInGroup);

                    Dictionary<string, string> parms = new Dictionary<string, string>();
                    parms.Add("act", act);
                    parms.Add("CertificateSlt", certificateid.ToString());
                    parms.Add("CourseSlt", courseid.ToString());
                    //parms.Add("RelationSlt", relationid.ToString());
                    mypager = pager.DrawPager("selfpager", parms);
                }
            }

        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}
